
 import { MessageBox } from "element-ui"
 
 export const confirm=(message,title="提示")=>{
    return new Promise((resolve,reject)=>{
       MessageBox.confirm(message,title,{
         callback(action){
             switch(action){
                 case "confirm":
                     resolve();
                     break;
                 case "cancel":
                     reject();
                     break;
             }
         }
       });
    });
 }
 
 export const deepClone=(source)=>{
     const newObj= Array.isArray(source)?[]:{};  
     const clone=(dest,sour)=>{
        for (const key in sour) {
         if (Object.hasOwnProperty.call(sour, key)) {
             const item = sour[key];
             if(item instanceof RegExp){
                 dest[key]=new RegExp(item);
             }else if(item instanceof Date){
                 dest[key]=new Date(item)
             }
             else if(item instanceof Object){
                 clone((dest[key]=Array.isArray(item)?[]:{}),item)
             }else{
                 dest[key]=item;
             }
           }
        }
     }
     clone(newObj,source)
     return newObj
 }